package com.satan.fmmall.controller;

import com.satan.fmmall.cache.Cache;
import com.satan.fmmall.service.CategoryService;
import com.satan.fmmall.service.IndexImgService;
import com.satan.fmmall.service.ProductService;
import com.satan.fmmall.vo.ResultVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @ClassName IndexController
 * @Description TODO
 * @date 2022/4/3 23:17
 * @Version 1.0
 */
@RequestMapping("/index")
@RestController
@Api(value = "提供首页数据显示所需的接口",tags = "首页管理")
public class IndexController {
    @Resource
    private IndexImgService indexImgService;
    @Resource
    private CategoryService categoryService;
    @Resource
    private ProductService productService;
    @Cache(expire = 60*1000,name = "listIndexImgs")
    @GetMapping("/index-img")
    @ApiOperation("首页轮播图接口")
    public ResultVo listIndexImgs() {
        return indexImgService.listIndexImgs();
    }
    @Cache(expire = 60*1000,name = "listCategory")
    @GetMapping("/category-list")
    @ApiOperation("商品分类查询接口")
    public ResultVo listCategory(){
        return categoryService.listCategories();
    }
    @Cache(expire = 60*1000,name = "listRecommendProducts")
    @GetMapping("/list-recommends")
    @ApiOperation("查询商品推荐接口")
    public ResultVo listRecommendProducts(){
        return productService.listRecommendProducts();
    }
    @Cache(expire = 60*1000,name = "listRecommendProductsByCategory")
    @GetMapping("/list-category-recommends")
    @ApiOperation("分类推荐接口")
    public ResultVo listRecommendProductsByCategory(){
        return categoryService.listFirstLevelCategories();
    }


}
